package com.bjpowernode.crm.workbench.clue.service.Impl;

import com.bjpowernode.crm.commons.PagationVo;
import com.bjpowernode.crm.settings.domain.DicValue;
import com.bjpowernode.crm.settings.mapper.DicValueMapper;
import com.bjpowernode.crm.workbench.clue.service.ClueService;
import com.bjpowernode.crm.workbench.domain.Activity;
import com.bjpowernode.crm.workbench.domain.Clue;
import com.bjpowernode.crm.workbench.domain.ClueRemark;
import com.bjpowernode.crm.workbench.mapper.ActivityMapper;
import com.bjpowernode.crm.workbench.mapper.ClueActivityRelationMapper;
import com.bjpowernode.crm.workbench.mapper.ClueMapper;
import com.bjpowernode.crm.workbench.mapper.ClueRemarkMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * ClassName: ClueServiceImpl<br/>
 * Package: com.bjpowernode.crm.workbench.clue.service.Impl<br/>
 * Description: <br/>
 * Date: 2022/7/10 3:11<br/>
 * Auther:对的我写的，错的我同事写的<br/>
 */
@Service
public class ClueServiceImpl implements ClueService {

    @Resource
    private ClueMapper clueMapper;
    @Resource
    private DicValueMapper dicValueMapper;
    @Resource
    private ClueRemarkMapper clueRemarkMapper;
    @Resource
    private ActivityMapper activityMapper;
    @Resource
    private ClueActivityRelationMapper activityRelationMapper;
    @Override
    public PagationVo<Clue> selectClues(Map paramMap) {
        PagationVo pagationVo = new PagationVo();
        List<Clue> clueList = clueMapper.selectByClueMap(paramMap);
        pagationVo.setDataList(clueList);
        Integer total = clueMapper.selectClueNums(paramMap);
        pagationVo.setTotal(total);
        return pagationVo;
    }

    @Override
    public List<DicValue> selectSourceAndState(String date) {
        return dicValueMapper.selectSourceAndState(date);
    }

    @Override
    public Integer insertClue(Clue clue) {

        return clueMapper.insertSelective(clue);
    }

    @Override
    public Clue selectclueById(String id) {

        return clueMapper.selectByPrimaryKey2(id);
    }

    @Override
    public Integer updateClue(Clue clue) {
        return clueMapper.updateByPrimaryKeySelective(clue);
    }

    @Override
    public Integer delectClueByIds(String[] ids) {
        return clueMapper.delectClueByIds(ids);
    }

    @Override
    public List<ClueRemark> selectRemarkById(String id) {
         return clueRemarkMapper.selectRemarkById(id);
    }

    @Override
    public Integer insertClueRemark(ClueRemark remark) {
        return clueRemarkMapper.insertSelective(remark);
    }

    @Override
    public List<Activity> selectActivitiesByClueId(String clueId) {

        return activityMapper.selectActivitiesByClueId(clueId);

    }

    @Override
    public Integer deleteActivityByactivityIdAndclueId(Map map) {
        return activityRelationMapper.deleteActivityByactivityIdAndclueId(map);
    }

    @Override
    public List<Activity> selectActivityByactivityIdAndclueId(Map map) {

        return activityMapper.selectActivityByactivityIdAndclueId(map);
    }

    @Override
    public Integer insertClueActivityRelation(List list) {
        return activityRelationMapper.insertClueActivityRelation(list);
    }
}
